
 begintownscript;	

 variables;
int i,j,k,r1,choice;
short charwho;
string char1;
body;
beginstate INIT_STATE;
	if (get_flag(6,5) == 5) {
		erase_char(6);
		set_terrain(7,24,388);
		set_terrain(26,24,388);
		set_incidental_sound(1);
}

	 break;	

beginstate START_STATE;
	if ((get_attitude(6) == 10) && (get_flag(6,4) == 0)) {
		set_character_pose(6,1);
		force_instant_terrain_redraw();
		pause(2);
		put_jagged_zap(17,7,14,8,4);
		put_jagged_zap(17,7,16,9,4);
		put_jagged_zap(17,7,17,9,4);
		put_jagged_zap(17,7,19,8,4);
		run_animation_sound(61);
		force_instant_terrain_redraw();
		pause(4);
		put_sparkles_on_space(14,8,11,4);
		put_sparkles_on_space(16,9,11,4);
		put_sparkles_on_space(17,9,11,4);
		put_sparkles_on_space(19,8,11,4);
		force_instant_terrain_redraw();
		run_animation_sound(75);
		activate_hidden_group(1);
		set_character_pose(6,0);
		force_instant_terrain_redraw();
		set_flag(6,4,1);
}
break;	

beginstate EXIT_STATE;
break;

beginstate 10;
	reset_dialog();
	add_dialog_str(0,"The portal flickers and ripples like they always do. Do you want to step through it and return to the ogre caves?",0);
	add_dialog_choice(0,"Nay!.");
	add_dialog_choice(1,"Yea!");
	choice = run_dialog(1);

	if (choice == 1)
		block_entry(1);

	if (choice == 2) {
		play_sound(10);
		message_dialog("The trip back is as gut wrenching as the trip into this place.","");
		move_to_new_town(5,6,21);
}
 break;

beginstate 11;

	if (get_flag(6,1) == 1)
		end();

	reset_dialog();
	add_dialog_str(0,"You browse Aprillia's bookshelf. There is not much of interest in it: a few basic tomes of alchemy and magic, maps of Valorim, some kind of book of religion and a trashy novel. There is one interesting piece of writing in the bookshelf, though.",0);
	add_dialog_str(1,"It has been written on an old frail piece of parchment. As is customary, its writer has scribbled the markings in strange symbols. You think you might be able to figure them out. Given enough time.",0);
	add_dialog_choice(0,"Try to decipher the runes.");
	add_dialog_choice(1,"Move on.");
	choice = run_dialog(1);
	

	if ((choice == 1) && (get_skill_total(42) >= 16)) {

		message_dialog("There you go. This was not so hard. The runes instruct you how to Create illusions using magic and having served their purpose, they fade away","If a party member has the necessary skill, he will learn a new spell. If a party member knew the spell already their skill casting it may improve.");
		charwho = 0;
		reset_dialog();
		while (charwho < party_size()) {

		clear_buffer();
		append_char_name(charwho);
		if ((get_stat(charwho,11) >= 6) && (get_spell_level(charwho,0,8) > 0) && (get_spell_level(charwho,0,8) < 3)) {
			append_string(" learns a new level of Create Illusions.");
			change_spell_level(charwho,0,8,1);
				}
		if ((get_stat(charwho,11) >= 6) && (get_spell_level(charwho,0,8) == 0)) {
			append_string(" learns a new spell - Create Illusions.");
			change_spell_level(charwho,0,8,1);
											}
		if ((get_stat(charwho,11) >= 6) && (get_spell_level(charwho,0,8) > 3))
			append_string(" learns nothing new.");
		if (get_stat(charwho,11) < 6)
			append_string(" is not skilled enough in magic.");
		get_buffer_text(char1);
		add_dialog_str(charwho,char1,0);
		

		charwho = charwho + 1;

		
}
		if (charwho == party_size()) {
			run_dialog(1);
			set_flag(6,1,1);
			award_party_xp(25,13);
			}
}
	if ((choice == 1) && (get_skill_total(42) < 16))
		message_dialog("Alas! The runes are too complex for you to decipher. If only you knew more about Arcane Lore.","");
 break;

beginstate 12;
	if ((get_flag(6,2) == 0) && (get_flag(7,7) != 5)) {
		block_entry(1);
		march_party(17,16);
		force_view_center(17,16);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(2);
		march_party(16,15);
		force_view_center(16,15);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(2);
		march_party(16,14);
		force_view_center(16,14);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(2);
		march_party(16,13);
		force_view_center(16,13);
		play_sound(-49);
		force_instant_terrain_redraw();
		pause(10);
		set_flag(6,2,1);
		begin_talk_mode(1);
}
	if ((get_flag(6,2) == 0) && (get_flag(7,7) == 5)) {
		set_total_visibility(1);
		force_view_center(17,14);
		force_instant_terrain_redraw();
		pause(2);
		force_view_center(17,12);
		force_instant_terrain_redraw();
		pause(2);
		force_view_center(17,10);
		force_instant_terrain_redraw();
		pause(2);
		force_view_center(17,8);
		force_instant_terrain_redraw();
		pause(10);
		text_bubble_on_char(6,"Too late!");
		force_instant_terrain_redraw();
		pause(9);
		text_bubble_on_char(6,"");
		force_instant_terrain_redraw();
		text_bubble_on_char(6,"Vengeance is mine!");
		force_instant_terrain_redraw();
		pause(14);
		put_boom_on_char(6,2,0);
		run_animation_sound(10);
		force_instant_terrain_redraw();
		pause(1);
		erase_char(6);
		force_instant_terrain_redraw();
		pause(8);
		force_view_center(char_loc_x(0),char_loc_y(0));
		set_total_visibility(0);
		force_instant_terrain_redraw();
		pause(12);
		message_dialog("The woman, presumably the witch of the ogres, has vanished. She teleported herself away before you had the chance to even consider your options. With her gone the entire caverns suddenly seem dead quiet.","Just what exactly did she mean by _vengeance_?");
		set_terrain(7,24,388);
		set_terrain(26,24,388);
		set_incidental_sound(1);
		set_flag(6,2,1);
		set_flag(6,5,5);
}
		
 break;

beginstate 13;
	if (get_flag(6,3) == 0) {
		message_dialog("Up ahead you can see two large fire pits lighting a large room. The light the fire creates allows you to study the room from out here. It is very empty. You see two large pillars holding the roof up and a platform.","On the platform stands a small, slim robed figure. The figure is small when compared to the ogres you have seen so far, but it is pretty small for a human as well and that is what it is: a human.");
		set_flag(6,3,1);
}
 break;

beginstate 14;

	if (get_flag(7,7) != 5)
		message_dialog("You look at this pedestal and blink in amazement. Aprillia could apparently make scrying pools, for you see a miniature Passton on the pedestal. The pool which holds the image is only about eight inches in diameter, so it is hard to notice much details.","You can, however, make out people walking on the streets of Passton. You cannot think of any practical use for the scrying pool so you leave it be.");

	if (get_flag(7,7) == 5)
		message_dialog("You look at this pedestal and blink in amazement. You are looking into a tiny scrying pool directed at what looks like Passton - Passton in ruins. The barracks has had a section of its walls torn down. You see several bodies littered around town.","Moving all over the tiny pool, you make out several ogres gleefully tearing the town apart.");
 break;
